Exercise: Harmonographs
In this exercise, you will solve tasks related to harmonographs.
We'll cover the following
Task 1#
As discussed in the previous lesson, below is the equation for a damped pendulum:
Problem Statement#
Write a Python function named pendulum() to implement the equation given above. Use the following default values for the parameters:
Use the following arguments to plot the output of the function against :
Set the range of to be the following:
Use all the suitable packages that you have learned throughout the course.
Task 2#
Now we will implement the harmonograph along the x and y axes and plot the output.
Problem Statement#
Use the function defined above to plot a harmonograph along the and direction. Implement the following equations:
Set the range of to be with values in it.
Plot the output of against .
Set the range of to be with values in it.
Change the values of the function arguments to see how the output changes. You will be amazed by these geometric patterns.
Use all the suitable packages that you have learned throughout the course.
Task 3#
If you have reached this part of the exercise, you must be wondering what possible patterns you can plot by supplying varying arguments to the function. In this task, you will be completely randomizing the output of the harmonograph.
Problem Statement#
Using the function above, implement the following random behavior in your code:
For both and pendulums, generate:
-
A random number of pendulums in the range: .
-
Random frequencies in the range: .
-
Random amplitudes in the range: .
-
Random phases in the range: .
-
Random decay factors in the range: .
Plot the randomly generated against . Use the following randomization when plotting the data:
- Break the data set into equal parts, where can take any random integer value in the range .
- Plot each slice of data with a different color, which will also be randomly generated.
Make sure to add labels to your plots.
Use all the suitable packages that you have learned throughout the course.
After you complete this task, run the code to see how the output changes with each execution.
The solution to this exercise will be discussed in the next lesson.
Preview: Harmonographs
Solution Review: Harmonographs